use std::{io, cmp::Ordering};
use rand::Rng;

fn main() {
    println!("Let's play a game\nGuess the number(0-100)!");
    println!("Enter Your Guess");
    let s_secret = rand::thread_rng().gen_range(1..101);
    loop {
        let mut guess = String::new();
        io::stdin().read_line(&mut guess)
        .expect("Failed to read line");
        let guess: u32 = match guess.trim().parse(){
            Ok(num)=>num,
            Err(_)=>continue,
        };
        match guess.cmp(&s_secret) {
            Ordering::Equal=>{println!("Correct"); break;},
            Ordering::Greater => println!("Bigger"),
            Ordering::Less => println!("Smaller"),
        }
    }
}
